package Presentation.GraphicUI;

import Domain.Exceptions.UserNotLoggedInException;

import javax.swing.*;
import java.util.TreeMap;

public class MainPanel extends MovieSystemPanel {

    private JLabel m_msg;

    public MainPanel(MainScreen mainScreen) {
        super(mainScreen);

        //m_msg=new JLabel("Please select any action");
        JLabel[] label = new JLabel[1];
        add(createInstructionLabel("Please select any action",label));        
        m_msg = label[0]; 

        TreeMap<Integer, JButton> actionButtons = new TreeMap<Integer, JButton>();
        actionButtons.put(1,createNavigationButton("Add a new Movie",MainScreen.ADD_MOVIE_PANEL));
        actionButtons.put(2,createNavigationButton("Get recommendation",MainScreen.GET_RECOMMENDATION_PANEL));
        actionButtons.put(3,createNavigationButton("Add recommendation",MainScreen.ADD_RECOMMENDATION_PANEL));

        TreeMap<Integer, JButton> adminButtons = new TreeMap<Integer, JButton>();
        adminButtons.put(1,createLogoutButton());

        add(createButtonsPanel(actionButtons));
        add(createButtonsPanel(adminButtons));
    }

    public void setUp(){
        try {
            String user = m_controller.getCurrentUser().getUsername();
            m_msg.setText("Hello "+user+", Please select any action");
        } catch (UserNotLoggedInException e) {
            m_msg.setText("Please select any action");
        }

    }
}
